/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//Load player api asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
//안전벨트 공익광고:OeRkiHXjk6M
//대만 상받은 보험광고:632CHpeHYZE
function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '720',
        width: '1280',
        videoId: 'OeRkiHXjk6M',
        playerVars: { 'autoplay': 1, 'controls': 0, 'showinfo':0, 'suggestedQuality': 'large'},
        events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
        }
    });
}
function onPlayerReady(evt) {
    evt.target.setVolume(100);
    evt.target.playVideo();
}
function onPlayerStateChange(evt) {
    if (evt.data == YT.PlayerState.ENDED) {
        Console.log("replay!");
        play();
    }
}
function stopVideo() {
    player.stopVideo();
}
function play() {
    if(player)
        player.playVideo();
}
function volumeControl(){
    if(player)
        player.setVolume(100);
}
function run(){
    setInterval(play,200);
    setInterval(volumeControl,200);
}